﻿using System;
using System . Collections . Generic;
using System . Linq;
using System . Text;
using System . Xml . Linq;

namespace GameClassLibrary . Calendars
{
    public class Calendar : GameObject
    {
        public List<CalendarEvent> EventList { get; private set; } = new List<CalendarEvent> ( );

        public List<CalendarEvent> GetEvents ( DateTime date )
        {
            var eventList=from evt in EventList
                          where evt.Date==date
                          select evt;

            List<CalendarEvent> temp=new List<CalendarEvent>();

            temp . AddRange ( eventList );

            return temp;
        }

        public Calendar ( XElement saving ) : base ( saving )
        {
            foreach ( var item in saving . Ancestors ( ) )
            {
                EventList . Add ( new CalendarEvent ( item ) );
            }
        }

        public override XElement Save ( )
        {
            XElement temp= base . Save ( );
            foreach ( var item in EventList )
            {
                temp . Add ( item . Save ( ) );
            }
            return temp;
        }

        public override void NextDay ( )
        {

        }
    }
}
